home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / MotionBlur.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  5.0 KB  |  186 lines

  1. /*
  2. ** $VER: MotionBlur.ieb 1.12, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 2/2 1997 Stockholm/Sweden
  6. **
  7. ** Create motion blur effect on image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Angle=0 ; Length=32 ; Step=2 ; MixVal=20
  42.  
  43.   if command ~= '' then parse var command '#'Method '#'Direc Angle Length Step MixVal
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Motion Blur" " OK | Cancel "',
  48.   ' TEXT,"Motion Blur creates a `sweeping` blur effect in the desired direction."'
  49.  
  50.   if command = '' then form = form||' CYCLE,"Method:","Mix (blurring)|Max (brighten)|Min (darken)",0',
  51.  
  52.   form = form||' INTEGER,"Mix sharpness (Mix method only)",0,100,'MixVal',SLIDER',
  53.   ' INTEGER,"Angle:",-1800,1800,'Angle',SLIDER',
  54.   ' INTEGER,"Length:",1,256,'Length',SLIDER',
  55.   ' INTEGER,"Step:",1,32,'Step',SLIDER'
  56.  
  57.   if command = '' then form = form||' CHECKBOX,"Blur both edges?",0'
  58.  
  59.   form
  60.  
  61.   if command = '' then do
  62.     parse var result ok Method MixVal Angle Length Step Direc .
  63.     if ok = 0 then return '<ERROR'
  64.     select
  65.       when Method = 0 then Method = "MIX"
  66.         when Method = 1 then Method = "MAX"
  67.         when Method = 2 then Method = "MIN"
  68.     end
  69.   end
  70.   else do
  71.     parse var result ok MixVal Angle Length Step .
  72.     if ok = 0 then return '<ERROR'
  73.  
  74.     Method = 'none'
  75.     Direc = 'none'
  76.   end
  77.  
  78.   back = '#'Method '#'strip(Direc) Angle Length Step MixVal
  79. return back
  80.  
  81. /* Required "Process_image" procedure  ------------------------------- */
  82.  
  83. process_image:
  84.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  85.   parse var options '#'Method '#'Direc Angle Length Step MixVal
  86.  
  87.   if add_mathlib() = '<ERROR>' then return '<ERROR>'
  88.  
  89.   'OPEN' '"'src_image'"' '24'
  90.   if (RC ~= 0) then do
  91.     'IE_TO_FRONT'
  92.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  93.     return '<ERROR>'
  94.   end
  95.   else LoadImage = result
  96.  
  97.   'PROJECT_INFO' LoadImage 'WIDTH'  /* image width */
  98.   IW = RESULT
  99.   'PROJECT_INFO' LoadImage 'HEIGHT' /* image height */
  100.   IH = RESULT
  101.  
  102.   do until ((Angle < 360)&(Angle >= 0))
  103.     if Angle > 359 then Angle = Angle - 360
  104.     if Angle < 0 then Angle = Angle + 360
  105.   end
  106.  
  107.   if Method = 'MIX' then Method = 'MIX' MixVal
  108.   Angle = Angle * 3.14159265 /180
  109.  
  110.   if Direc = 0 then do  /* single */
  111.     'SCALE' LoadImage IW IH 'FAST'
  112.     BackImage = Result
  113.  
  114.     do i = 1 to Length by Step
  115.       'MARK' LoadImage 'PRIMARY'
  116.       'MARK' BackImage 'SECONDARY'
  117.       'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method
  118.       TempImage = Result
  119.       'CLOSE' BackImage
  120.       BackImage = TempImage
  121.     end
  122.  
  123.     'CLOSE' LoadImage
  124.     OutputImage = BackImage
  125.   end
  126.   else do  /* both */
  127.     do i = 1 to Length by Step
  128.       'MARK' LoadImage 'PRIMARY'
  129.       'MARK' LoadImage 'SECONDARY'
  130.       'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method
  131.       TempImage = Result
  132.       'CLOSE' LoadImage
  133.       LoadImage = TempImage
  134.     end
  135.  
  136.     OutputImage = LoadImage
  137.   end
  138.  
  139.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  140.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  141.   if (RC ~= 0) then do
  142.     'IE_TO_FRONT'
  143.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  144.     return '<ERROR>'
  145.   end
  146.   'CLOSE' OutputImage
  147.  
  148.   back = 'OK'
  149. return back
  150.  
  151. /* Internal procedures  ---------------------------------------------- */
  152.  
  153. add_mathlib:
  154.   if ~show(L,'rexxmathlib.library') then do
  155.     if exists('LIBS:rexxmathlib.library') then do
  156.       if ~addlib('rexxmathlib.library',0,-30,0) then do
  157.         'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "'
  158.         return '<ERROR>'
  159.       end
  160.     end /* lib found on disk */
  161.     else do
  162.       'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "'
  163.       return '<ERROR>'
  164.     end
  165.   end /* lib exists in mem */
  166. return 'OK'
  167.  
  168. /*******************************************************************/
  169. /* This is where control goes when an error code is returned by IE */
  170. /* It puts up a message saying what happened and on which line     */
  171. /*******************************************************************/
  172.  
  173. error:
  174. if RC=5 then do
  175.     IE_TO_FRONT
  176.     LAST_ERROR
  177.     'REQUEST "'||RESULT||'"'
  178. end
  179. else do
  180.     IE_TO_FRONT
  181.     LAST_ERROR
  182.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  183. end
  184.  
  185. return '<ERROR>'
  186.